<?php

namespace app\listener\pay;

use app\common\service\around\JtkAroundService;
use app\event\PaySuccess;
use app\model\CouponOrder;

/**
 * 支付成功后 周边游 -聚推客的 产品下单
 */
class AroundCreateOrder
{

    /**
     * 事件监听处理
     * @param PaySuccess $event
     * @return mixed
     */
    public function handle($event)
    {
        $payLog = $event->obj;
        /**
         * @var CouponOrder $couponOrder
         */
        $couponOrder = $payLog->couponOrder;

        if ($couponOrder->serv_type != PRODUCT_AROUND_SHOP_SERV) {
            return true;
        }

        if ($couponOrder->type != CouponOrder::TYPE_COUPON_SELF_EMPLOYED) {
            return true;
        }

        // 聚推客周边游订单推送
        (new JtkAroundService())->createOrder($couponOrder);

    }
}